CC		= gcc -g -Wall -D_GNU_SOURCE -O0 -std=c99 -D_XOPEN_SOURCE=500
GCOV    = -ftest-coverage -fprofile-arcs
CFLAGS	= -I./lemonheader/ -I./common/ -I./masterserver/ -I./chunkserver/ -I./client/ -I./protocol -I./storage_module -pthread -lm
LIB     = common/lfs_common.a

LEMONHEADER_SRC = lemonheader/*.c
MASTER_SRC = masterserver/*.c
CHUNKSERVER_SRC = chunkserver/*.c
PROTOCOL_SRC = protocol/*.c
CLIENT_SRC = client/*.c
COMMON_SRC = common/*.c
STORAGE_MODULE_SRC = storage_module/*.c

UNITTEST_TESTING_SRC = testing/*.c
UNITTEST_MASTER_SRC  = testing/unittest/masterserver/*.c
UNITTEST_CHUNKSERVER_SRC  = testing/unittest/chunkserver/*.c
UNITTEST_STORAGE_MODULE = testing/unittest/storage_module/*.c

all:	auto_unittest

lfs_common:
	cd common; make

sample:
	$(CC) $(CFLAGS) ${CLIENT_SRC} ${UNITTEST_TESTING_SRC} $(LIB) -D SAMPLE_CASE -D _STD_DEBUG_  -o sample

##################################### Auto Unittest #####################################

auto_unittest:
	$(CC) $(CFLAGS) ${LEMONHEADER_SRC} ${UNITTEST_COMMON_SRC} ${UNITTEST_MASTER_SRC} ${UNITTEST_CHUNKSERVER_SRC}  ${UNITTEST_STORAGE_MODULE} -D _STD_DEBUG_ testing/unittest/auto_unittest.c $(COMMON_SRC) $(MASTER_SRC) $(CHUNKSERVER_SRC) $(CLIENT_SRC) $(PROTOCOL_SRC) $(STORAGE_MODULE_SRC) -D AUTO_UNITTEST -o auto_unittest
	
####################################### module ########################################

clean:
	rm *.gcno *.gcda *.info *_unittest
